package com.lwc.cfdns.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 我的配置
 *
 * @author luwc
 * @title AppConfig
 * @description
 * @time 2023/6/2 13:37:08
 * @version: 1.0
 */
@Component
@ConfigurationProperties(prefix = "app")
@Configuration
public class AppConfig {
    private static UsersProperties users;

    // 自动记录接口操作日志
    private static boolean autoOperLog = false;
    // 是否记录执行结果
    private static boolean operLogResult = false;
    // 附件驱动
    private static String attachmentStorage;

    public static String getAttachmentStorage() {
        return attachmentStorage;
    }

    public synchronized void setAttachmentStorage(String attachmentStorage) {
        AppConfig.attachmentStorage = attachmentStorage;
    }

    public static boolean getAutoOperLog() {
        return autoOperLog;
    }

    public synchronized void setAutoOperLog(boolean autoOperLog) {
        AppConfig.autoOperLog = autoOperLog;
    }

    public static boolean getOperLogResult() {
        return operLogResult;
    }

    public synchronized void setOperLogResult(boolean operLogResult) {
        AppConfig.operLogResult = operLogResult;
    }

    public static UsersProperties getUsers() {
        return users;
    }

    public static void setUsers(UsersProperties users) {
        AppConfig.users = users;
    }

    public static class UsersProperties {
        private static long loginPwdNum = 5l;
        private static long loginLockTime = 600l;

        public static long getLoginPwdNum() {
            return loginPwdNum;
        }

        public synchronized void setLoginPwdNum(long loginPwdNum) {
            UsersProperties.loginPwdNum = loginPwdNum;
        }

        public static long getLoginLockTime() {
            return loginLockTime;
        }

        public synchronized void setLoginLockTime(long loginLockTime) {
            UsersProperties.loginLockTime = loginLockTime;
        }
    }
}